package com.yilin.tms.core.entity.order.clearing;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yilin.tms.core.commons.base.BaseDataEntity;
import com.yilin.tms.core.entity.order.goods.GoodsOrder;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;

/**
 * 清算明细表
 * 清算明细 用于记录 运单最终由平台核定的费用明细
 * 任何一条运单都必须有清算明细，自动/手动
 * 司机费用全部来源于清算明
 * 货主费用手动清算时可能会被重新核定
 * @Author: zhangjinyuan
 * @CreateTime: 2023-02-15  09:33
 */
@Entity
@Table(name = "order_clearing_detail")
@TableName(value = "order_clearing_detail")
public class ClearingDetail extends BaseDataEntity {

    /**
     * 清算状态
     */
    public enum ClearingStatus {
        going(0, "清算进行"),
        success(1, "清算成功"),
        scrap(2, "已作废");
        @EnumValue
        public Integer index;
        public String name;

        ClearingStatus(Integer index, String name) {
            this.index = index;
            this.name = name;
        }
    }

    /**
     * 清算锁定状态
     */
    public enum LockStatus {
        unLock(0, "待锁定"),
        lock(1, "已锁定");
        @EnumValue
        public Integer index;
        public String name;

        LockStatus(Integer index, String name) {
            this.index = index;
            this.name = name;
        }
    }
    /**
     * 清算类型
     */
    public enum ClearingType {
        auto(0, "自动清算"),
        manual(1, "手动清算");
        @EnumValue
        public Integer index;
        public String name;

        ClearingType(Integer index, String name) {
            this.index = index;
            this.name = name;
        }
    }

    /**
     * 基本信息
     */
    @Column(name = "clearing_order_no")
    private String clearingOrderNo;//清算单号
    @Column(name = "clearing_status")
    private ClearingStatus clearingStatus;//清算状态
    @Column(name = "clearing_type")
    private ClearingType clearingType; //清算类型
    /**
     * 运单信息
     */
    @Column(name = "transit_order_id")
    private String transitOrderId;//运单ID
    @Column(name = "transit_order_no")
    private String transitOrderNo;//运单号
    @Column(name = "gather_record_id")
    private String gatherRecordId;//汇总记录ID
    @Column(name = "gather_record_no")
    private String gatherRecordNo;//汇总记录编号
    @Column(name = "matchmaking")
    private Boolean matchmaking;//是否撮合业务
    @Column(name = "included_tax")
    private Boolean includedTax;//运费是否含税
    /**
     * 货主信息
     */
    @Column(name = "shipper_organize_id")
    private String shipperOrganizeId;//货主组织id
    @Column(name = "shipper_organize_name")
    private String shipperOrganizeName;//货主组织名称 公司名称 所有权人
    @Column(name = "shipper_account_id")
    private String shipperAccountId; //货主id
    @Column(name = "shipper_account_name")
    private String shipperAccountName;//货主名称
    /**
     * 车主信息
     */
    @Column(name = "rob_organize_id")
    private String robOrganizeId;//车主组织id
    @Column(name = "rob_organize_name")
    private String robOrganizeName;//车主组织/公司/所有人名称
    @Column(name = "rob_account_id")
    private String robAccountId;//车主id
    @Column(name = "rob_account_name")
    private String robAccountName;//车主名称
    /**
     * 清算操作人【平台】
     */
    @Column(name = "lock_status")
    private LockStatus lockStatus = LockStatus.unLock; //清算操作人ID
    @Column(name = "lock_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date lockTime;//操作锁定时间
    @Column(name = "opt_account_id")
    private String optAccountId; //清算操作人ID
    @Column(name = "opt_account_name")
    private String optAccountName;//清算操作人名称
    @Column(name = "opt_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date optTime;//最后操作时间
    /**
     * 货主费用信息
     */
    @Column(name = "shipper_fee_rate")
    private Double shipperFeeRate; // 货主手续费率
    @Column(name = "shipper_tax_rate")
    private Double shipperTaxRate;// 货主预付不含税税率
    @Column(name = "insurance_rate")
    private Double insuranceRate; // 保率[保费跟随运单，不在汇总范畴]
    //-值
    @Column(name = "shipper_transport_cost")
    private Double shipperTransportCost; //货主运输费
    @Column(name = "shipper_fee_cost")
    private Double shipperFeeCost;  //货主手续费
    @Column(name = "additional_cost")
    private Double additionalCost = 0D; //附加费用总费用 例：装卸费
    @Column(name = "shipper_tax_cost")
    private Double shipperTaxCost = 0D;//货主运单不含税增收税费(货主发布的运费不含税的情况下)
    @Column(name = "insurance_cost")
    private Double insuranceCost;//保费
    @Column(name = "insurance_amount")
    private Double insuranceAmount;//保额
    @Column(name = "already_pay_cost")
    private Double alreadyPayCost;//货主清算前已付款金额
    @Column(name = "shipper_actual_pay_cost")
    private Double shipperActualPayCost;//货主最终实际支付的总费用
    @Column(name = "actual_settlement_type")
    private GoodsOrder.SettlementType actualSettlementType;//最终结算方式
    /**
     * 车主费用信息
     */
    @Column(name = "trucker_fee_rate")
    private Double truckerFeeRate; // 车主手续费率
    @Column(name = "added_tax_rate")
    private Double addedTaxRate; //-增值税率
    @Column(name = "city_tax_rate")
    private Double cityTaxRate; //-城建税率 基于增值税
    @Column(name = "local_edu_tax_rate")
    private Double localEduTaxRate; //-地方教育税率 基于增值税
    @Column(name = "edu_add_tax_rate")
    private Double eduAddTaxRate; //-教育附加税率 基于增值税
    @Column(name = "income_tax_rate")
    private Double incomeTaxRate; //-个人所得税率
    //-值
    @Column(name = "trucker_fee_cost")
    private Double truckerFeeCost = 0D; //平台服务费--司机
    @Column(name = "diff_indemnity_cost")
    private Double diffIndemnityCost = 0D; //磅差/货损 赔偿--司机
    @Column(name = "diff_indemnity_detail",columnDefinition = "TEXT")
    private String diffIndemnityDetail; // 赔付详情，详细说明
    @Column(name = "oil_cost")
    private Double oilCost = 0D;//油费--司机
    @Column(name = "etc_toll_cost")
    private Double etcTollCost = 0D;//ETC过路费--司机
    @Column(name = "added_tax_cost")
    private Double addedTaxCost = 0D;  //增值税
    @Column(name = "city_tax_cost")
    private Double cityTaxCost = 0D;//城建税 基于增值税
    @Column(name = "local_edu_tax_cost")
    private Double localEduTaxCost = 0D;//地方教育税 基于增值税
    @Column(name = "edu_add_tax_cost")
    private Double eduAddTaxCost = 0D;//教育附加税 基于增值税
    @Column(name = "income_tax_cost")
    private Double incomeTaxCost = 0D;//个人所得税

    @Column(name = "trucker_tax_cost")
    private Double truckerTaxCost = 0D; //TODO:实际扣除司机总税费

    @Column(name = "trucker_actual_theory_cost")
    private Double truckerActualTheoryCost= 0D;//平台最终付款给司机的费用
    @Column(name = "technical_fee_cost")
    private Double technicalFeeCost= 0D;  //TODO:通道服务费 恢复司机
    @Column(name = "trucker_actual_income_cost")
    private Double truckerActualIncomeCost= 0D;//平台最终付款给司机的费用

    //上级服务费仅记录  不显示
    @Column(name = "plat_operate_fee")
    private Double platOperateFee = 0D; //平台（网货>孵化）运营服务费
    @Column(name = "zone_operate_fee")
    private Double zoneOperateFee = 0D; //平台（孵化>社区）运营服务费
    //上级服务费仅记录  不显示
    @Column(name = "plat_technical_fee")
    private Double platTechnicalFee = 0D; //平台（网货>孵化）技术服务费
    @Column(name = "zone_technical_fee")
    private Double zoneTechnicalFee = 0D; //平台（孵化>社区）技术服务费

    public Double getTechnicalFeeCost() {
        return technicalFeeCost;
    }

    public void setTechnicalFeeCost(Double technicalFeeCost) {
        this.technicalFeeCost = technicalFeeCost;
    }

    public Double getPlatTechnicalFee() {
        return platTechnicalFee;
    }

    public void setPlatTechnicalFee(Double platTechnicalFee) {
        this.platTechnicalFee = platTechnicalFee;
    }

    public Double getZoneTechnicalFee() {
        return zoneTechnicalFee;
    }

    public void setZoneTechnicalFee(Double zoneTechnicalFee) {
        this.zoneTechnicalFee = zoneTechnicalFee;
    }

    public Double getTruckerActualTheoryCost() {
        return truckerActualTheoryCost;
    }

    public void setTruckerActualTheoryCost(Double truckerActualTheoryCost) {
        this.truckerActualTheoryCost = truckerActualTheoryCost;
    }

    public Double getPlatOperateFee() {
        return platOperateFee;
    }

    public void setPlatOperateFee(Double platOperateFee) {
        this.platOperateFee = platOperateFee;
    }

    public Double getZoneOperateFee() {
        return zoneOperateFee;
    }

    public void setZoneOperateFee(Double zoneOperateFee) {
        this.zoneOperateFee = zoneOperateFee;
    }

    public String getDiffIndemnityDetail() {
        return diffIndemnityDetail;
    }

    public void setDiffIndemnityDetail(String diffIndemnityDetail) {
        this.diffIndemnityDetail = diffIndemnityDetail;
    }

    public LockStatus getLockStatus() {
        return lockStatus;
    }

    public void setLockStatus(LockStatus lockStatus) {
        this.lockStatus = lockStatus;
    }

    public Double getInsuranceAmount() {
        return insuranceAmount;
    }

    public void setInsuranceAmount(Double insuranceAmount) {
        this.insuranceAmount = insuranceAmount;
    }

    public String getClearingOrderNo() {
        return clearingOrderNo;
    }

    public void setClearingOrderNo(String clearingOrderNo) {
        this.clearingOrderNo = clearingOrderNo;
    }

    public ClearingStatus getClearingStatus() {
        return clearingStatus;
    }

    public void setClearingStatus(ClearingStatus clearingStatus) {
        this.clearingStatus = clearingStatus;
    }

    public ClearingType getClearingType() {
        return clearingType;
    }

    public void setClearingType(ClearingType clearingType) {
        this.clearingType = clearingType;
    }

    public String getTransitOrderId() {
        return transitOrderId;
    }

    public void setTransitOrderId(String transitOrderId) {
        this.transitOrderId = transitOrderId;
    }

    public String getTransitOrderNo() {
        return transitOrderNo;
    }

    public void setTransitOrderNo(String transitOrderNo) {
        this.transitOrderNo = transitOrderNo;
    }

    public String getGatherRecordId() {
        return gatherRecordId;
    }

    public void setGatherRecordId(String gatherRecordId) {
        this.gatherRecordId = gatherRecordId;
    }

    public String getGatherRecordNo() {
        return gatherRecordNo;
    }

    public void setGatherRecordNo(String gatherRecordNo) {
        this.gatherRecordNo = gatherRecordNo;
    }

    public Boolean getMatchmaking() {
        return matchmaking;
    }

    public void setMatchmaking(Boolean matchmaking) {
        this.matchmaking = matchmaking;
    }

    public Boolean getIncludedTax() {
        return includedTax;
    }

    public void setIncludedTax(Boolean includedTax) {
        this.includedTax = includedTax;
    }

    public String getShipperOrganizeId() {
        return shipperOrganizeId;
    }

    public void setShipperOrganizeId(String shipperOrganizeId) {
        this.shipperOrganizeId = shipperOrganizeId;
    }

    public String getShipperOrganizeName() {
        return shipperOrganizeName;
    }

    public void setShipperOrganizeName(String shipperOrganizeName) {
        this.shipperOrganizeName = shipperOrganizeName;
    }

    public String getShipperAccountId() {
        return shipperAccountId;
    }

    public void setShipperAccountId(String shipperAccountId) {
        this.shipperAccountId = shipperAccountId;
    }

    public String getShipperAccountName() {
        return shipperAccountName;
    }

    public void setShipperAccountName(String shipperAccountName) {
        this.shipperAccountName = shipperAccountName;
    }

    public String getRobOrganizeId() {
        return robOrganizeId;
    }

    public void setRobOrganizeId(String robOrganizeId) {
        this.robOrganizeId = robOrganizeId;
    }

    public String getRobOrganizeName() {
        return robOrganizeName;
    }

    public void setRobOrganizeName(String robOrganizeName) {
        this.robOrganizeName = robOrganizeName;
    }

    public String getRobAccountId() {
        return robAccountId;
    }

    public void setRobAccountId(String robAccountId) {
        this.robAccountId = robAccountId;
    }

    public String getRobAccountName() {
        return robAccountName;
    }

    public void setRobAccountName(String robAccountName) {
        this.robAccountName = robAccountName;
    }

    public Date getLockTime() {
        return lockTime;
    }

    public void setLockTime(Date lockTime) {
        this.lockTime = lockTime;
    }

    public String getOptAccountId() {
        return optAccountId;
    }

    public void setOptAccountId(String optAccountId) {
        this.optAccountId = optAccountId;
    }

    public String getOptAccountName() {
        return optAccountName;
    }

    public void setOptAccountName(String optAccountName) {
        this.optAccountName = optAccountName;
    }

    public Date getOptTime() {
        return optTime;
    }

    public void setOptTime(Date optTime) {
        this.optTime = optTime;
    }

    public Double getShipperFeeRate() {
        return shipperFeeRate;
    }

    public void setShipperFeeRate(Double shipperFeeRate) {
        this.shipperFeeRate = shipperFeeRate;
    }

    public Double getShipperTaxRate() {
        return shipperTaxRate;
    }

    public void setShipperTaxRate(Double shipperTaxRate) {
        this.shipperTaxRate = shipperTaxRate;
    }

    public Double getInsuranceRate() {
        return insuranceRate;
    }

    public void setInsuranceRate(Double insuranceRate) {
        this.insuranceRate = insuranceRate;
    }

    public Double getShipperTransportCost() {
        return shipperTransportCost;
    }

    public void setShipperTransportCost(Double shipperTransportCost) {
        this.shipperTransportCost = shipperTransportCost;
    }

    public Double getShipperFeeCost() {
        return shipperFeeCost;
    }

    public void setShipperFeeCost(Double shipperFeeCost) {
        this.shipperFeeCost = shipperFeeCost;
    }

    public Double getAdditionalCost() {
        return additionalCost;
    }

    public void setAdditionalCost(Double additionalCost) {
        this.additionalCost = additionalCost;
    }

    public Double getShipperTaxCost() {
        return shipperTaxCost;
    }

    public void setShipperTaxCost(Double shipperTaxCost) {
        this.shipperTaxCost = shipperTaxCost;
    }

    public Double getInsuranceCost() {
        return insuranceCost;
    }

    public void setInsuranceCost(Double insuranceCost) {
        this.insuranceCost = insuranceCost;
    }

    public Double getAlreadyPayCost() {
        return alreadyPayCost;
    }

    public void setAlreadyPayCost(Double alreadyPayCost) {
        this.alreadyPayCost = alreadyPayCost;
    }

    public Double getShipperActualPayCost() {
        return shipperActualPayCost;
    }

    public void setShipperActualPayCost(Double shipperActualPayCost) {
        this.shipperActualPayCost = shipperActualPayCost;
    }

    public GoodsOrder.SettlementType getActualSettlementType() {
        return actualSettlementType;
    }

    public void setActualSettlementType(GoodsOrder.SettlementType actualSettlementType) {
        this.actualSettlementType = actualSettlementType;
    }

    public Double getTruckerFeeRate() {
        return truckerFeeRate;
    }

    public void setTruckerFeeRate(Double truckerFeeRate) {
        this.truckerFeeRate = truckerFeeRate;
    }

    public Double getAddedTaxRate() {
        return addedTaxRate;
    }

    public void setAddedTaxRate(Double addedTaxRate) {
        this.addedTaxRate = addedTaxRate;
    }

    public Double getCityTaxRate() {
        return cityTaxRate;
    }

    public void setCityTaxRate(Double cityTaxRate) {
        this.cityTaxRate = cityTaxRate;
    }

    public Double getLocalEduTaxRate() {
        return localEduTaxRate;
    }

    public void setLocalEduTaxRate(Double localEduTaxRate) {
        this.localEduTaxRate = localEduTaxRate;
    }

    public Double getEduAddTaxRate() {
        return eduAddTaxRate;
    }

    public void setEduAddTaxRate(Double eduAddTaxRate) {
        this.eduAddTaxRate = eduAddTaxRate;
    }

    public Double getIncomeTaxRate() {
        return incomeTaxRate;
    }

    public void setIncomeTaxRate(Double incomeTaxRate) {
        this.incomeTaxRate = incomeTaxRate;
    }

    public Double getTruckerFeeCost() {
        return truckerFeeCost;
    }

    public void setTruckerFeeCost(Double truckerFeeCost) {
        this.truckerFeeCost = truckerFeeCost;
    }

    public Double getDiffIndemnityCost() {
        return diffIndemnityCost;
    }

    public void setDiffIndemnityCost(Double diffIndemnityCost) {
        this.diffIndemnityCost = diffIndemnityCost;
    }

    public Double getOilCost() {
        return oilCost;
    }

    public void setOilCost(Double oilCost) {
        this.oilCost = oilCost;
    }

    public Double getEtcTollCost() {
        return etcTollCost;
    }

    public void setEtcTollCost(Double etcTollCost) {
        this.etcTollCost = etcTollCost;
    }

    public Double getAddedTaxCost() {
        return addedTaxCost;
    }

    public void setAddedTaxCost(Double addedTaxCost) {
        this.addedTaxCost = addedTaxCost;
    }

    public Double getCityTaxCost() {
        return cityTaxCost;
    }

    public void setCityTaxCost(Double cityTaxCost) {
        this.cityTaxCost = cityTaxCost;
    }

    public Double getLocalEduTaxCost() {
        return localEduTaxCost;
    }

    public void setLocalEduTaxCost(Double localEduTaxCost) {
        this.localEduTaxCost = localEduTaxCost;
    }

    public Double getEduAddTaxCost() {
        return eduAddTaxCost;
    }

    public void setEduAddTaxCost(Double eduAddTaxCost) {
        this.eduAddTaxCost = eduAddTaxCost;
    }

    public Double getIncomeTaxCost() {
        return incomeTaxCost;
    }

    public void setIncomeTaxCost(Double incomeTaxCost) {
        this.incomeTaxCost = incomeTaxCost;
    }

    public Double getTruckerTaxCost() {
        return truckerTaxCost;
    }

    public void setTruckerTaxCost(Double truckerTaxCost) {
        this.truckerTaxCost = truckerTaxCost;
    }

    public Double getTruckerActualIncomeCost() {
        return truckerActualIncomeCost;
    }

    public void setTruckerActualIncomeCost(Double truckerActualIncomeCost) {
        this.truckerActualIncomeCost = truckerActualIncomeCost;
    }
}
